package com.ocom.payhandle.controller;

import com.ocom.common.constant.PayHandleUrl;
import com.ocom.common.entity.card.EntityXfRecordProcess;
import com.ocom.common.enums.ResultEnum;
import com.ocom.common.request.payhandle.GetRecordProcessRequest;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.common.vo.payconfig.kitchenprinter.GoodsListProcessDishesDto;
import com.ocom.payhandle.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j
@RestController
public class GoodsListProcessController {

	@Autowired
	private XfGoodsListProcessService xfGoodsListProcessService;

	@Autowired
	private XfRecordProcessService xfRecordProcessService;

	@PostMapping(PayHandleUrl.URL_getGoodsListProcessOnDishes)
	public Result getGoodsListProcessOnDishes(@RequestParam("comId") Long comId, @RequestParam("orderNo") String orderNo){
		List<GoodsListProcessDishesDto> list = xfGoodsListProcessService.getGoodsListProcessOnDishes(comId, orderNo);
		return ResultUtil.success(list);
	}


	@PostMapping(PayHandleUrl.URL_PayHandle_getRecordProcess)
	public Result getRecordProcess(@RequestBody GetRecordProcessRequest request){
		EntityXfRecordProcess entityXfRecordProcess =xfRecordProcessService.selectTradeNo(request.getCompanyId(),request.getTradeNo(),request.getMachNo());

		if (entityXfRecordProcess ==null){
			return ResultUtil.error(ResultEnum.Err_1001);
		}
		return  ResultUtil.success(entityXfRecordProcess);
	}

}
